#ifndef OPENCVTHREAD_H
#define OPENCVTHREAD_H

#include <QThread>
#include <QPixmap>
#include <QApplication>
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <vector>
#include <QDebug>
#include <QByteArray>

#define ON_THE_GREEN_CHANNEL 120   // 绿色 通道上限
#define UNDER_THE_GREEN_CHANNEL 85 // 绿色通道下
using namespace std;
using namespace cv;

class OpenCvThread : public QThread
{
    Q_OBJECT
public:
    explicit OpenCvThread(QObject *parent = 0);
    ~OpenCvThread();
    bool runFlog;
    int redCount;
    int greenCount;
    bool isFirstDetectedR;
    bool isFirstDetectedG;
    Rect *lastTrackBoxR;
    Rect *lastTrackBoxG;
    int lastTrackNumR;
    int lastTrackNumG;
    QPixmap getNewAiData() const;
    int getRedCount() const;
    int getGreenCount() const;

protected:
    void run();
    int processImgR(Mat, Mat &);
    int processImgG(Mat, Mat &);
    bool isIntersected(Rect, Rect);
    QByteArray oldDaya;
    QPixmap newAiData;
signals:
    newAiDataSignal();
public slots:
    void newDataSlot(QByteArray);
};

#endif // OPENCVTHREAD_H
